#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include <dirent.h>
#include <sys/stat.h>
#include <pthread.h>
#include <limits.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdatomic.h>

#define NUM_THREADS 4

struct ThreadData {
    int thread_id;
    long long start;
    long long end;
    char source_path[PATH_MAX];
    char dest_path[PATH_MAX];
};

struct BackupTask {
    const char *source;
    const char *destination;
    const char *way;
};

extern pthread_mutex_t mutex;
extern long long total_bytes;                // 总字节数
extern _Atomic long long *completed_bytes;   // 已备份字节数（指向原子长整型变量的指针） 

void copy_file(const char *source_path, const char *dest_path);
void *copy_file_threaded(void *arg);
void copy_directory(const char *source, const char *destination);
void copy_large_file_multithreaded(const char *source_path, const char *dest_path);
